<template>
  <div>
    <van-icon name="arrow-left" @click="router.back()" />
    <div class="video-content">
      <video :src="videoUrl" controls show-progress show-fullscreen-btn=false show-center-play-btn></video>
      <!-- 或者动态更改 -->
      <button @click="switchVideo(1)">第一章</button>
      <button @click="switchVideo(2)">第二章</button>
    </div>
  </div>
</template>

<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";

const videoUrl = ref("http://vjs.zencdn.net/v/oceans.mp4");
const router = useRouter();
function switchVideo(num) {
  if(num===1){
    videoUrl.value = "http://vjs.zencdn.net/v/oceans.mp4";
  }else if(num===2){
    videoUrl.value = "https://media.w3.org/2010/05/sintel/trailer.mp4";
  }
}
</script>

<style scoped>
video {
  width: 100%;
  height: 100px;
}
</style>